<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
</head>
<body>
<!-- Content Header (Page header) -->
<section class="content-header">
    <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> 系统管理</a></li>
        <li class="active">平台会员管理</li>
    </ol>
</section>

<!-- Main content -->
<section class="content">
    <div class="box">
        <div class="box-header">
            <button class="btn btn-success btn-sm" id="addMpingtHyxx"><i class="fa fa-plus"></i> &nbsp;&nbsp;添加会员</button>
        </div>
        <!-- /.box-header -->
        <div class="box-body">
            <table id="mpingtHyxxList" class="table table-bordered table-striped" data-striped="true">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>会员号</th>
                    <!--th>微信会员号</th-->
                    <!--th>密码</th-->
                    <th>会员昵称</th>
                    <th>会员等级</th>
                    <th>会员积分</th>
                    <th>会员姓名</th>
                    <th>性别</th>
                    <!--th>身份证号</th-->
                    <!--th>出生日期</th-->
                    <th>电话</th>
                    <!--th>邮箱</th-->
                    <!--th>QQ</th-->
                    <!--th>住址</th-->
                    <!--th>注册时间</th-->
                    <th>会员到期时间</th>
                    <th>最后登录时间</th>
                    <th>备注</th>
                    <th>有效标志</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <tr th:each="entity,stat :${page.entityList}">
                    <td th:text="${stat.count}">1</td>
                    <td th:text="${entity.bianh}">会员编号</td>
                    <!--td th:text="${entity.weixbh}">微信号</td-->
                    <!--td th:text="${entity.mim}">密码</td-->
                    <td th:text="${entity.mingc}">会员昵称</td>
                    <td th:text="${entity.mpingtHydjId}">会员等级</td>
                    <td th:text="${entity.huiyjf}">会员积分</td>
                    <td th:text="${entity.xingm}">会员姓名</td>
                    <td th:text="${entity.xingb}">性别</td>
                    <!--td th:text="${entity.shenfzh}">身份证号</td-->
                    <!--td>
                        <span th:if="${entity.chusrq !=null}"  th:text="${#dates.format(entity.chusrq,'yyyy-MM-dd')}">出生日期
                    </span>
                    </td-->
                    <td th:text="${entity.dianh}">电话</td>
                    <!--td th:text="${entity.email}">邮箱</td-->
                    <!--td th:text="${entity.qq}">QQ</td-->
                    <!--td th:text="${entity.diz}">住址</td-->
                    <!--td>
                        <span th:if="${entity.zhucsj !=null}"  th:text="${#dates.format(entity.zhucsj,'yyyy-MM-dd')}">注册时间</span>
                    </td-->
                    <td>
                        <span th:if="${entity.daoqsj !=null}"  th:text="${#dates.format(entity.daoqsj,'yyyy-MM-dd')}">会员到期时间</span>
                    </td>
                    <td>
                        <span th:if="${entity.zuijdlsj !=null}"  th:text="${#dates.format(entity.zuijdlsj,'yyyy-MM-dd')}">最后登录时间</span>
                    </td>
                    <td th:text="${entity.beiz}">备注</td>
                    <td >
                        <span class="label label-info" th:class="${entity.youxbz==1 ? 'label label-info':'label label-danger'}" th:text="${entity.youxbz==1 ? '有效':'无效'}"></span>
                        &nbsp;&nbsp;
                        <span data-toggle="tooltip" title="作废或恢复xx" th:class="${entity.youxbz==1 ? 'btn btn-xs btn-danger':'btn btn-xs btn-info'}"
                              th:onclick="'zfMpingtHyxx(\''+${entity.id}+'\',\''+${entity.youxbz==1?1:0}+'\');'" >
                            <i class="fa  fa-arrow-right"></i>
                            <span th:text="${entity.youxbz==1 ? '作废':'恢复'}"></span></span>
                    </td>
                    <td>
                        <div>
                                <span data-toggle="tooltip" title="编辑xx信息" class="btn btn-xs btn-info"
                                      th:onclick="'editMpingtHyxx(\''+${entity.id}+'\');'">
                                    <i class="fa fa-edit"></i> 编辑</span>

                            <span data-toggle="tooltip" title="删除xx" class="btn btn-xs btn-danger"
                                  th:onclick="'delMpingtHyxx(\''+${entity.id}+'\');'"><i class="fa fa-trash-o"></i> 删除</span>
                        </div>
                        <div>
                            <span><i class="fa fa-lock"></i></span>
                        </div>
                    </td>
                </tbody>
            </table>
            <!---分页工具条-->
            <div id="pagination" class="col-sm-2"></div>
        </div>


    </div>
</section>

<!-- 新增或修改的模态框 -->
<div class="modal fade" id="mpingtHyxxModal" tabindex="-1" role="dialog"
     aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"
                        aria-hidden="true">&times;
                </button>
                <h4 class="modal-title text-center" id="mpingtHyxxmodelHead">添加会员</h4>
            </div>
            <div class="modal-body">

                <input type="hidden" name="page_mpingtHyxx_url" value=""/>
                <input type="hidden" name="type" value=""/>

                <form id="add_edit_form" class="form-horizontal" role="form">
                        <input type="hidden" name="id" value=""/>
                    <div class="form-group">
                        <label for="bianh" class="col-sm-3 control-label">会员编号<label style="color: red">*</label></label>
                        <div class="col-sm-9">
                                    <input type="text" class="form-control" name="bianh" value="" id="bianh"
                                           placeholder="请输入会员编号">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="mim" class="col-sm-3 control-label">密码<label style="color: red">*</label></label>
                        <div class="col-sm-9">
                                    <input type="text" class="form-control" name="mim" value="" id="mim"
                                           placeholder="请输入密码">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="mpingtHydjId" class="col-sm-3 control-label">会员等级<label style="color: red">*</label></label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="mpingtHydjId" value="" id="mpingtHydjId"
                                   placeholder="请输入会员等级">

                        </div>
                    </div>
                    <div class="form-group">
                        <label for="mingc" class="col-sm-3 control-label">会员昵称<label style="color: red">*</label></label>
                        <div class="col-sm-9">
                                    <input type="text" class="form-control" name="mingc" value="" id="mingc"
                                           placeholder="请输入会员昵称">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="xingb" class="col-sm-3 control-label">性别<label style="color: red">*</label></label>
                        <div class="col-sm-9">
                            <!--input type="text" class="form-control" name="xingb" value="" id="xingb"
                                   placeholder="请输入性别"-->

                            <select class="form-control" name="xingb" value="" id="xingb"
                                    placeholder="请选择">
                                <option value="0">请选择...</option>
                                <option value="1">男</option>
                                <option value="2">女 </option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="dianh" class="col-sm-3 control-label">联系电话<label style="color: red">*</label></label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="dianh" value="" id="dianh"
                                   placeholder="请输入电话">
                        </div>
                    </div>
                    <hr/>
                    <div class="form-group">
                        <label for="xingm" class="col-sm-3 control-label">会员姓名</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="xingm" value="" id="xingm"
                                   placeholder="请输入会员姓名">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="huiyjf" class="col-sm-3 control-label">会员积分</label>
                        <div class="col-sm-9">
                                    <input type="text" class="form-control" name="huiyjf" value="" id="huiyjf"
                                           placeholder="请输入会员积分">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="shenfzh" class="col-sm-3 control-label">身份证号</label>
                        <div class="col-sm-9">
                                    <input type="text" class="form-control" name="shenfzh" value="" id="shenfzh"
                                           placeholder="请输入身份证号">
                        </div>
                    </div>

                    <div class="form-group">
                        <label for="chusrq" class="col-sm-3 control-label">出生日期</label>
                        <div class="col-sm-9">
                                <input type="date" class="form-control" name="chusrq" value="" id="chusrq"
                                       placeholder="请输入出生日期">
                        </div>
                    </div>
                    <hr/>
                    <div class="form-group">
                        <label for="email" class="col-sm-3 control-label">邮箱</label>
                        <div class="col-sm-9">
                                    <input type="text" class="form-control" name="email" value="" id="email"
                                           placeholder="请输入邮箱">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="weixbh" class="col-sm-3 control-label">微信号</label>
                        <div class="col-sm-9">
                            <input type="text" class="form-control" name="weixbh" value="" id="weixbh"
                                   placeholder="请输入微信号">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="qq" class="col-sm-3 control-label">QQ</label>
                        <div class="col-sm-9">
                                    <input type="text" class="form-control" name="qq" value="" id="qq"
                                           placeholder="请输入QQ">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="diz" class="col-sm-3 control-label">住址</label>
                        <div class="col-sm-9">
                                    <input type="text" class="form-control" name="diz" value="" id="diz"
                                           placeholder="请输入住址">
                        </div>
                    </div>
                    <hr/>
                    <div class="form-group">
                        <label for="zhucsj" class="col-sm-3 control-label">注册时间</label>
                        <div class="col-sm-9">
                                <input type="date" class="form-control" name="zhucsj" value="" id="zhucsj" readonly="readonly"
                                       placeholder="请输入注册时间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="daoqsj" class="col-sm-3 control-label">会员到期时间</label>
                        <div class="col-sm-9">
                                <input type="date" class="form-control" name="daoqsj" value="" id="daoqsj"
                                       placeholder="请输入会员到期时间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="zuijdlsj" class="col-sm-3 control-label">最后登录时间</label>
                        <div class="col-sm-9">
                                <input type="date" class="form-control" name="zuijdlsj" value="" id="zuijdlsj"
                                       placeholder="请输入最后登录时间">
                        </div>
                    </div>
                    <div class="form-group">
                        <label for="beiz" class="col-sm-3 control-label">备注</label>
                        <div class="col-sm-9">
                                    <input type="text" class="form-control" name="beiz" value="" id="beiz"
                                           placeholder="请输入备注">
                        </div>
                    </div>
                        <input type="hidden" name="youxbz" value=""/>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" data-dismiss="modal">关闭</button>
                <button type="submit" class="btn btn-success" id="imgSubmit">确定</button>
            </div>
        </div>
    </div>
</div>


<script th:inline="javascript">

$(function () {
        //提示框
     $("[data-toggle='tooltip']").tooltip();

    //分页工具条设置
    var options = {
        bootstrapMajorVersion:1,
        currentPage: [[ ${page.number}+1]],//当前页数
        totalPages: [[ ${page.totalPages}==0?1:  ${page.totalPages}]],//总页数
        numberOfPages:5,    //最多显示Page页
        size:"normal" ,//设置控件的显示大小，是个字符串. 允许的值: mini, small, normal,large。值：mini版的、小号的、正常的、大号的。
        itemTexts: function(type, page, current) { //修改显示文字
            switch (type) {
                case "first":
                    return "首页";
                case "prev":
                    return "上一页";
                case "next":
                    return "下一页";
                case "last":
                    return "末页";
                case "page":
                    return page;
            }
        },
        pageUrl: function(type, page, current){
            return "/member/mpingtHyxx/page?page="+page;
        }
    };
    $("#pagination").bootstrapPaginator(options);

    //添加按钮方法
    $("#addMpingtHyxx").click(function () {
        reloadModelData("/member/mpingtHyxx/add", "添加xx", "添加",null,"add");
        $("#mpingtHyxxModal").modal("show");
    });

    //确认按钮
    $("#imgSubmit").click(function () {
        var _page_mpingtHyxx_url = $("input[name='page_mpingtHyxx_url']").val();
        var _type = $("input[name='type']").val();
        var _id = $("input[name='id']").val();
        var _bianh = $("input[name='bianh']").val();
        var _weixbh = $("input[name='weixbh']").val();
        var _mim = $("input[name='mim']").val();
        var _mingc = $("input[name='mingc']").val();
        var _mpingtHydjId = $("input[name='mpingtHydjId']").val();
        var _huiyjf = $("input[name='huiyjf']").val();
        var _xingm = $("input[name='xingm']").val();
        var _xingb = $("select[name='xingb']").val();
        var _shenfzh = $("input[name='shenfzh']").val();
        var _chusrq = $("input[name='chusrq']").val();
        var _dianh = $("input[name='dianh']").val();
        var _email = $("input[name='email']").val();
        var _qq = $("input[name='qq']").val();
        var _diz = $("input[name='diz']").val();
        var _zhucsj = $("input[name='zhucsj']").val();
        var _daoqsj = $("input[name='daoqsj']").val();
        var _zuijdlsj = $("input[name='zuijdlsj']").val();
        var _beiz = $("input[name='beiz']").val();
        var _youxbz = $("input[name='youxbz']").val();

        if (_bianh == '' || _bianh == undefined) {
            alert("会员号不能为空");
            return false;
        }
        if (_mim == '' || _mim == undefined) {
            alert("会员号不能为空");
            return false;
        }
        if (_mpingtHydjId == '' || _mpingtHydjId == undefined) {
            alert("会员等级不能为空");
            return false;
        }
        if (_xingb == '' || _xingb == undefined) {
            alert("性别不能为空");
            return false;
        }
        if (_mingc == '' || _mingc == undefined) {
            alert("昵称不能为空");
            return false;
        }
        if (_dianh == '' || _dianh == undefined) {
            alert("联系电话不能为空");
            return false;
        }

        var _data;
        _data={
                id: _id,
                bianh: _bianh,
                weixbh: _weixbh,
                mim: _mim,
                mingc: _mingc,
                mpingtHydjId: _mpingtHydjId,
                huiyjf: _huiyjf,
                xingm: _xingm,
                xingb: _xingb,
                shenfzh: _shenfzh,
                chusrq: _chusrq,
                dianh: _dianh,
                email: _email,
                qq: _qq,
                diz: _diz,
                zhucsj: _zhucsj,
                daoqsj: _daoqsj,
                zuijdlsj: _zuijdlsj,
                beiz: _beiz,
                youxbz: _youxbz };


        //验证非空
        //        if (_type == 'add') {
        //            if (!checkAccount(_bianh, _xingm, _mim)) {
        //                return false;
        //            }
        //        }

        $.ajax({
            type: "post",
            url: _page_mpingtHyxx_url,
            cache: false,
            dataType: "json",
            data: _data,
            success: function (data) {
                var code = data.code || data.result.code;
                var msg = data.msg || data.result.msg;
                if (code == '1') {
                    $("#mpingtHyxxModal").modal("hide");
                    method.msg_pro("更新成功！",1000,function () {
                        window.location.href = window.location.href;
                    });
                } else {
                    method.msg_alert("提示", msg);
                }
            },
            error:function (data) {
                var msg = data.msg || data.result.msg;
                method.msg_alert("提示", msg);
            }
        });
    });
});

//作废恢复xx
function zfMpingtHyxx(Id,_bz) {

    method.msg_confirm("提示","你确定要作废或恢复此xx吗？",function(){
        $.ajax({
            type:"POST",
            url:"/member/mpingtHyxx/zouf",
            dataType:"json",
            data:{id:Id,bz:_bz},
            cache:false,
            success:function(data){
                var code = data.code || data.result.code;
                var msg = data.msg || data.result.msg;
                if(code== '1'){
                    method.msg_pro("操作成功！",1000,function () {
                        window.location.href = window.location.href;
                    });
                }else{
                    method.msg_alert("提示", msg);
                }
            },
            error:function (data) {
                var msg = data.msg || data.result.msg;
                method.msg_alert("提示", msg);
            }
        });
    });
}



//删除xx
function delMpingtHyxx(Id) {
    method.msg_confirm("提示","你确定要删除此xx吗？",function(){
        $.ajax({
            type:"POST",
            url:"/member/mpingtHyxx/del",
            dataType:"json",
            data:{id:Id},
            cache:false,
            success:function(data){
                var code = data.code || data.result.code;
                var msg = data.msg || data.result.msg;
                if(code== '1'){
                    method.msg_pro("删除成功！",1000,function () {
                        window.location.href = window.location.href;
                    });
                }else{
                    method.msg_alert("提示", msg);
                }
            },
            error:function (data) {
                var msg = data.msg || data.result.msg;
                method.msg_alert("提示", msg);
            }
        });
    });
}
//编辑xx
function editMpingtHyxx(Id) {

    $.ajax({
        type:"POST",
        url:"/member/mpingtHyxx/get",
        dataType:"json",
        data:{id:Id},
        cache:false,
        success:function(data){
            var code = data.code || data.result.code;
            var msg = data.msg || data.result.msg;
            if(code== '1'){
                reloadModelData("/member/mpingtHyxx/edit", "编辑会员", "更新",data.resultObject, "edit");
                $("#mpingtHyxxModal").modal("show");
            }else{
                method.msg_alert("提示", msg);
            }
        },
        error:function (data) {
            var msg = data.msg || data.result.msg;
            method.msg_alert("提示", msg);
        }
    });
}

////验证数据
//function checkAccount(bianh, xingm, password) {
//    if (bianh == '') {
//        $("input[name='bianh']").focus();
//        alert("登录名不能为空");
//        return false;
//    }
//    return true;
//}
//加载模态框的数据
function reloadModelData(url,title,btntext,data,type) {
    $("#mpingtHyxxModal #mpingtHyxxmodelHead").text(title);
    $("#mpingtHyxxModal #imgSubmit").text(btntext);
    $("input[name='page_mpingtHyxx_url']").val(url);
    $("input[name='type']").val(type);

    if(data !=null && data !="" && type == "edit")
    {
                $("input[name='id']").val(data.id);
                $("input[name='bianh']").val(data.bianh);
                $("input[name='weixbh']").val(data.weixbh);
                $("input[name='mim']").val(data.mim);
                $("input[name='mingc']").val(data.mingc);
                $("input[name='mpingtHydjId']").val(data.mpingtHydjId);
                $("input[name='huiyjf']").val(data.huiyjf);
                $("input[name='xingm']").val(data.xingm);
                $("select[name='xingb']").val(data.xingb);
                $("input[name='shenfzh']").val(data.shenfzh);
                $("input[name='chusrq']").val(new Date(data.chusrq).Format("yyyy-MM-dd"));
                $("input[name='dianh']").val(data.dianh);
                $("input[name='email']").val(data.email);
                $("input[name='qq']").val(data.qq);
                $("input[name='diz']").val(data.diz);
                $("input[name='zhucsj']").val(new Date(data.zhucsj).Format("yyyy-MM-dd"));
                $("input[name='daoqsj']").val(new Date(data.daoqsj).Format("yyyy-MM-dd"));
                $("input[name='zuijdlsj']").val(new Date(data.zuijdlsj).Format("yyyy-MM-dd"));
                $("input[name='beiz']").val(data.beiz);
                $("input[name='youxbz']").val(data.youxbz);
        //设置是否可编辑
        $("input[name='id']").attr("disabled", true);
    }else{
        //清空界面上的内容
        $("input[name='id']").val("");
        $("input[name='bianh']").val("");
        $("input[name='weixbh']").val("");
        $("input[name='mim']").val("");
        $("input[name='mingc']").val("");
        $("input[name='mpingtHydjId']").val("");
        $("input[name='huiyjf']").val("");
        $("input[name='xingm']").val("");
        $("input[name='xingb']").val("");
        $("input[name='shenfzh']").val("");
        $("input[name='chusrq']").val("");
        $("input[name='dianh']").val("");
        $("input[name='email']").val("");
        $("input[name='qq']").val("");
        $("input[name='diz']").val("");
        $("input[name='zhucsj']").val("");
        $("input[name='daoqsj']").val("");
        $("input[name='zuijdlsj']").val("");
        $("input[name='beiz']").val("");
        $("input[name='youxbz']").val("");
        //设置是否可编辑
        $("input[name='id']").attr("disabled", false);
    }
}
</script>
</body>
</html>